package com.duanruan.bmgl.common;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * @author xiaolong
 * @create 2020-08-21 9:30
 * @description 传出数据的结果封装类
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class JsonData {
    //状态码
    private Integer code;

    //状态信息
    private String msg;

    //数据
    private Object data;

    public static JsonData success(Integer code,String msg,Object data){return new JsonData(code,msg,data);}

    public static JsonData success(String msg,Object data){return new JsonData(0,msg,data);}

    public static JsonData success(String msg){return new JsonData(0,msg,null);}

    public static JsonData fail(Integer code,String msg,Object data){return new JsonData(code,msg,data);}

    public static JsonData fail(String msg,Object data){return new JsonData(-1,msg,data);}

    public static JsonData fail(String msg){return new JsonData(-1,msg,null);}

}
